/**$Licence:
 *   Use this however/wherever you like, just don't blame me if it breaks anything.
 *   Copyright (C) 2008 - 2013 xingsheng.zhu@gmail.com All rights reserved.
 */
package com.blazemina.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author JackChu
 * @version 2.0.0 2013-2-19 下午5:32:16
 */
public class PropertyUtil {


	private Properties p = new Properties();

	public PropertyUtil(String propertyFile) {
		InputStream resourceAsStream = PropertyUtil.class.getClassLoader()
				.getResourceAsStream(propertyFile);
		try {
			p.load(resourceAsStream);
			resourceAsStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			resourceAsStream = null;
		}
	}

	/**
	 * 
	 * @param key
	 * @return
	 */
	public String getProperty(String key) {
		return p.getProperty(key);
	}

	/**
	 * 
	 * @param key
	 * @return
	 */
	public int getInt(String key) {
		String value = p.getProperty(key);
		if(value == null){
			return 0;
		}
		int returnValue = Integer.valueOf(value).intValue();
		return returnValue;
	}

	/**
	 * 
	 * @param key
	 * @return
	 */
	public boolean getBoolean(String key) {
		String value = p.getProperty(key);
		boolean returnValue = Boolean.valueOf(value).booleanValue();
		return returnValue;

	}

}
